﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TrimAttribute.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// <summary>
//   Defines the TrimAttribute type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.ComponentModel
{
    using Modelling;

    public class TrimAttribute : PropertyChangingAttribute
    {
        public override bool OnChanging(object instance, MetaModelProperty property, object oldValue, ref object newValue)
        {
            if (newValue != null)
            {
                newValue = ((string)newValue).Trim();
            }

            return true;
        }
    }
}
